package com.iuie.ns.devtools.element;

import java.util.Iterator;
import java.util.List;


public abstract class DevElement {

    protected abstract String getPrefix();

    protected abstract String getSuffix();
    
    protected abstract List<DevElement> getChildren();
    
    public String build() {
        StringBuilder sb = new StringBuilder(12);
        if (this.getPrefix() != null) {
        	sb.append(this.getPrefix());
        }
        List<DevElement> children = this.getChildren();
        if (children != null && children.size() > 0) {
	        Iterator<DevElement> it = children.iterator();
	        while(it.hasNext()) {
	            DevElement devEle = it.next();
	            String s = devEle.build();
	            sb.append(s);
	        }
        }
        if (this.getSuffix() != null) {
        	sb.append(this.getSuffix());
        }
        return sb.toString();
    }

}
